package com.zhaoyuxi.redpack.web;


import com.zhaoyuxi.redpack.service.ITbRedpackService;
import com.zhaoyuxi.redpack.service.ITbUserRedpackService;
import com.zhaoyuxi.redpack.service.RedisService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 赵玉玺
 * @since 2020-04-02
 */
@RestController
@RequestMapping("/tbRedpack")
public class TbRedpackController {

    @Autowired
    private RedisService redisService;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private ITbUserRedpackService iTbUserRedpackService;

    @RequestMapping("/none")
    public String getPack(){
        String pack = iTbUserRedpackService.getPackRedis();
        return  pack;
    }

    @RequestMapping("/rabbitmq")
    public String  getPack2(){
        rabbitTemplate.convertAndSend("redpack","抢红包");
        return "抢红包成功";
    }

    @RequestMapping("/sync")
    public void sync(){
        redisService.syncRedPack();
    }

    @RequestMapping("/delete")
    public void delete(){
        redisService.delete();
    }
}
